package cn.intcast.test;

import java.util.ArrayList;
import java.util.Collection;

class Person{
	String name;
	int age;
	public Person(String name, int age) {
		this.name=name;
		this.age=age;
	}
	
	@Override
	public int hashCode() {
		return this.name.hashCode()+age;
	}
	@Override
	public boolean equals(Object obj) {
		Person p=(Person)obj;
		return this.name.equals(p.name);
	}
	@Override
	public String toString() {
		return this.name+age;
	}
}

public class test01 {
	public static void main(String[] args) {
		Person p1=new Person("cainter",22);
		Person p2=new Person("cainter",22);
		Collection coll=new ArrayList();
		coll.add(p1);
		coll.add(p2);
		System.out.println(p1.equals(p2));
		System.out.println(coll);
		System.out.println(p1 instanceof Person);
	}
}
